<?php


namespace app\admin\controller;


use app\BaseController;
use think\facade\Db;
use think\facade\Session;
use think\facade\View;

class Login extends BaseController
{
    public function index(){
        return View::fetch();
    }
    public function login(){
        $username=input('username');
        $password=input('userpassword');
        $data=Db::name('users')->where('uname',$username)->find();
        if(!empty($data)){
            if($data['upassword']==md5($password)){
                Session::set('usession',$data['uname']);
                return json(['status'=>1000,'tips'=>'登陆成功！']);
            }else{
                return json(['status'=>1001,'tips'=>'用户名或密码错误！']);
            }
        }else{
            return json(['status'=>1001,'tips'=>'用户名或密码错误！']);
        }
    }
}